package com.is.demo.redis.controller;

import cn.hutool.db.nosql.redis.RedisDS;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;

/**
 * @author Will
 */
@Slf4j
@RestController
@RequestMapping("/redis/demo")
public class RedisController {

    @RequestMapping(path = "append")
    public Long append(String key, String value) {

        Jedis jedis = RedisDS.create().getJedis();
        Long append = jedis.append(key, value);
        jedis.close();
        return append;
    }

    @RequestMapping(path = "get")
    public String get(String key) {

        Jedis jedis = RedisDS.create().getJedis();
        String s = jedis.get(key);
        jedis.close();
        return s;
    }

}
